@extends('users.app')
@section('title', '数据清理')
@section('content')
@section('style')
<link rel="stylesheet" type="text/css" href="/assets/plugins/datepicker/css/tempusdominus-bootstrap-4.min.css">
@stop
@section('content')
  <div class="col-md-10 offset-md-1">
    <div class="card ">
      <div class="card-header">
        <h1>
          数据清理
        </h1>
      </div>
      <div class="card-body">
        @include('common.error')
        <form method="POST" action="{{ route('view_counts.destroy')}}">
          <input type="hidden" name="_method" value="DELETE">
          @csrf
        <div class="row">
        <div class="col-sm-6 col-md-3">
            <div class="form-group">
                <div class="input-group date" id="datetimepicker" data-target-input="nearest">
                    <div class="input-group-prepend">
                      <div class="input-group-text">起始日期</div>
                    </div>
                    <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker" name="date" value="{{ Request::input('date') }}" />
                    <div class="input-group-append" data-target="#datetimepicker" data-toggle="datetimepicker">
                        <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6 col-md-3">
            <div class="form-group">
                <div class="input-group date" id="datetimepicker_end" data-target-input="nearest">
                    <div class="input-group-prepend">
                      <div class="input-group-text">结束日期</div>
                    </div>
                    <input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker_end" name="date_end" value="{{ Request::input('date_end') }}"/>
                    <div class="input-group-append" data-target="#datetimepicker_end" data-toggle="datetimepicker_end">
                        <div class="input-group-text"><i class="fa fa-calendar"></i></div>
                    </div>
                </div>
            </div>
        </div>
        </div>
        <div class="pl-0 col-sm-10 offset-sm-1 col-md-3 offset-md-0">
          <div class="form-group text-righ">
            <button type="submit" class="btn btn-common">清理</button>
          </div>
        </div>
      </form>
      </div>
    </div>
  </div>

@endsection

@section('script')
<script src="/assets/plugins/moment/moment-2.24.0.js"></script>
<script src="/assets/plugins/datepicker/js/tempusdominus-bootstrap-4.min.js"></script>
<script>
  $(function () {
        $('#datetimepicker').datetimepicker({
          format: 'YYYY-MM-DD',
          allowInputToggle: true,
          maxDate: '{{ date('Y-m-d') }}',
          @if (Request::input('date'))
          useCurrent: false,
          defaultDate: '{{ Request::input('date') }}'
          @endif
        });
        $('#datetimepicker_end').datetimepicker({
          format: 'YYYY-MM-DD',
          allowInputToggle: true,
          maxDate: '{{date('Y-m-d')}}',
          @if (Request::input('date_end'))
          useCurrent: false,
          defaultDate: '{{Request::input('date_end')}}'
          @endif
        });
        $('#datetimepicker').on('change.datetimepicker', function(e){
          $('#datetimepicker_end').datetimepicker('minDate', e.date);
        });
        $('#datetimepicker_end').on('change.datetimepicker', function(e){
          $('#datetimepicker').datetimepicker('maxDate', e.date);
        });
    });
</script>
@stop
